package com.ljp.order.controller;

import com.ljp.order.io.Result;
import com.ljp.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService drivingOrderService;

    @PostMapping("/add/{userId}/{id}")
    @ResponseBody
    public Result addOrder(@PathVariable("userId") long userId, @PathVariable("id") long id) {
        return drivingOrderService.addOrder(userId, id);
    }


    @PostMapping("/queryOrder")
    @ResponseBody
    public Result fetchOrder(@RequestParam("id") long id) {
        return drivingOrderService.fetchOrder(id);
    }
}
